package com.idudiao.sc.common.log.event;

import com.dhcc.aml.common.core.dto.log.OperationLogDTO;
import com.idudiao.sc.common.log.feign.BasicFeign;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;

/**
 * 异步监听日志事件
 *
 * @author songyinyin
 * @date 2019/1/9 11:27
 */
@Slf4j
@AllArgsConstructor
public class OperationLogListener {

    private final BasicFeign basicFeign;

    @Async
    @Order
    @EventListener(OperationLogEvent.class)
    public void saveSysLog(OperationLogEvent event) {
        OperationLogDTO dto = (OperationLogDTO) event.getSource();
        basicFeign.add(dto);
    }
}
